home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 41.zip
/
BS1 part 41
/
Lattice C v5.02 d4.adf
/
examples
/
debugger
/
showprocess.cpr
< prev
next >
Wrap
Text File
|
1988-11-07
|
6KB
|
196 lines
/*
Usage: ShowProcess [<task name> | 0xnnnnnnnn]
Version 1.01 04-Nov-88
Displays the process structure for the given task. If none is specified,
the current task under debugger control is displayed. ShowProcess will
verify that the indicated task is a valid process before displaying the
information.
Note that because of the Amiga Scheduling, ShowProcess may not always be
able to find a task specified by name.
Output is displayed in the form:
--------------------------------
'RAW' in wait state at priority 5
Type 13 Flags 00 IDNestCnt 0 TDNestCnt -1
Signal: Alloc 0000FFFF Wait 00000100 Recvd 00000000 Except 00000000
Trap: Data 00000000 Code 00FF47EA Alloc 8000 Able 0000
Except: Data 00000000 Code 00FC2FF0
Stack: Reg 0027368E Lower 00272BFC Upper 002736EC
CPURegs: PC 00FC08F4 SR 0010
D: 0023D158 00000000 002721CC 00272778 00000009 00000052 00000057 00272B9C
A: 00FF4134 00272B40 00C04EC8 00FF9FF2 00FF4648 00C00240 00C00276
Process Dependent ---------------------------------------------
SegList $00200C6C StackSize $00000AF0 GlobVec $00C04EC8
TaskNum 0 StackBase $00272BFC Result2 0
CurrentDir $00000000 CIS $00000000 COS $00000000
ConsoleTask $0022F264 FileSysTask $00C00ADC CLI $00000000
ReturnAddr $002736E8 PktWait $00000000
*/
parse arg name '0x' tsk .
NULL = "00000000"x
if (name = '?') then
do
do i = 2 to 11
'd "'||strip(sourceline(i),'T',"0a"x) '"'
end
exit(0)
end
else if (name ~= '') then
do
taskbase = findtask(name)
name = "'"||name||"'"
end
else if (tsk ~= '') then
do
name = right(tsk,8,'0')
taskbase = x2c(name)
name = '0x'||name
end
else
do
options results
'd a7 %08x'
sp = left(result,8)
'tasks'
tasklist = result
options
/* Now figure out where the stack pointer should be */
sp = c2x(offset(x2c(sp),-118))
place = index(tasklist,sp)
if (place = 0) then place = 87
name = substr(tasklist, place-33, 8)
taskbase = x2c(name)
name = '0x'||name
end
statenm.0 = 'invalid'
statenm.1 = 'added'
statenm.2 = 'run'
statenm.3 = 'ready'
statenm.4 = 'wait'
statenm.5 = 'except'
statenm.6 = 'removed'
type = c2d(import(offset(taskbase,8),1))
if (type ~= 13 & type ~= 1) then do
'd' '"'||name 'is not a valid process"'
exit(0)
end
name = "'"||import(import(offset(taskbase,10),4))||"'"
state = c2d(import(offset(taskbase,15),1))
statename = statenm.state
pri = c2d(import(offset(taskbase,9),1))
'd' '"'||name 'in' statename 'state at priority' pri '"'
flags = c2x(import(offset(taskbase,14),1))
idnest = c2d(import(offset(taskbase,16),1),1)
tdnest = c2d(import(offset(taskbase,17),1),1)
'd' '"Type' type ' Flags' flags ' IDNestCnt' idnest ' TDNestCnt' tdnest '"'
sigalloc = c2x(import(offset(taskbase,18),4))
sigwait = c2x(import(offset(taskbase,22),4))
sigrec = c2x(import(offset(taskbase,26),4))
sigexcept = c2x(import(offset(taskbase,30),4))
'd' '"Signal: Alloc' sigalloc ' Wait ' sigwait ' Recvd' sigrec ' Except' sigexcept '"'
trapdata = c2x(import(offset(taskbase,46),4))
trapcode = c2x(import(offset(taskbase,50),4))
trapalloc = c2x(import(offset(taskbase,34),2))
trapable = c2x(import(offset(taskbase,36),2))
'd' '"Trap: Data ' trapdata ' Code ' trapcode ' Alloc' trapalloc ' Able' trapable '"'
excptdata = c2x(import(offset(taskbase,38),4))
excptcode = c2x(import(offset(taskbase,42),4))
'd' '"Except: Data ' excptdata ' Code ' excptcode '"'
sp = import(offset(taskbase,54),4)
spreg = c2x(sp)
splower = c2x(import(offset(taskbase,58),4))
spupper = c2x(import(offset(taskbase,62),4))
'd' '"Stack: Reg ' spreg ' Lower' splower ' Upper' spupper '"'
if (state >= 3 & state <= 6) then do
pc = c2x(import(sp, 4))
sr = c2x(import(offset(sp,4),2))
'd' '"CPURegs: PC ' pc ' SR ' sr '"'
dregs = c2x(import(offset(sp,6), 32))
dregs = insert(' ', dregs, 56);
dregs = insert(' ', dregs, 48);
dregs = insert(' ', dregs, 40);
dregs = insert(' ', dregs, 32);
dregs = insert(' ', dregs, 24);
dregs = insert(' ', dregs, 16);
dregs = insert(' ', dregs, 8);
'd' '"D:' dregs '"'
aregs = c2x(import(offset(sp,38), 28))
aregs = insert(' ', aregs, 48);
aregs = insert(' ', aregs, 40);
aregs = insert(' ', aregs, 32);
aregs = insert(' ', aregs, 24);
aregs = insert(' ', aregs, 16);
aregs = insert(' ', aregs, 8);
'd' '"A:' aregs '"'
end
if type = 13 then do
'd' '"Process Dependent ----------------------------------------------"'
seglist = "$"||c2x(d2c(c2d(import(offset(taskbase,128),4))*4,4))
stacksize = right(c2d(import(offset(taskbase,132),4)), 9)
globvec = "$"||c2x(import(offset(taskbase,136),4))
'd' '"SegList ' seglist ' StackSize ' stacksize ' GlobVec ' globvec '"'
tasknum = right(c2d(import(offset(taskbase,140),4)), 9)
stackbase = "$"||c2x(d2c(c2d(import(offset(taskbase,144),4))*4,4))
result2 = right(c2d(import(offset(taskbase,148),4)), 9)
'd' '"TaskNum ' tasknum ' StackBase ' stackbase ' Result2 ' result2 '"'
curdir = "$"||c2x(d2c(c2d(import(offset(taskbase,152),4))*4,4))
cis = "$"||c2x(d2c(c2d(import(offset(taskbase,156),4))*4,4))
cos = "$"||c2x(d2c(c2d(import(offset(taskbase,160),4))*4,4))
'd' '"CurrentDir ' curdir ' CIS ' cis ' COS ' cos '"'
contask = "$"||c2x(import(offset(taskbase,164),4))
filesys = "$"||c2x(import(offset(taskbase,168),4))
cli = "$"||c2x(d2c(c2d(import(offset(taskbase,172),4))*4,4))
'd' '"ConsoleTask' contask ' FileSysTask' filesys ' CLI ' cli '"'
retaddr = "$"||c2x(import(offset(taskbase,180),4))
pktwait = "$"||c2x(import(offset(taskbase,184),4))
'd' '"ReturnAddr ' retaddr ' PktWait ' pktwait '"'
end
exit 0
/* Locate a task in the system based upon the name */
findtask:
parse arg name
execbase = import("00000004"x,4)
liboff = 420
nodebase = import(offset(execbase, liboff), 4)
do while(import(nodebase,4) ~= NULL)
if import(import(offset(nodebase,10),4)) = name then return nodebase
nodebase = import(nodebase,4)
end
liboff = 406
nodebase = import(offset(execbase, liboff), 4)
do while(import(nodebase,4) ~= NULL)
if import(import(offset(nodebase,10),4)) = name then return nodebase
nodebase = import(nodebase,4)
end
'd' '"Could not find process' name||'"'
exit(0)